import Vue from 'vue'
import Router from 'vue-router'
// 导入 自定义的组件
import Customer from '@/views/Customer'
import Market from '@/views/Market'
import System from '@/views/System'

import Home from '@/components/Home'
import Login from '@/components/Login'
import index from '@/pages/index'

import CommonCustomer from '@/pages/customer/CommonCustomer'
import CustomerList from '@/pages/customer/CustomerList'
import AllOrder from '@/pages/market/AllOrder'
import MyOrder from '@/pages/market/MyOrder'
import SysRole from '@/pages/system/SysRole'
import SysMenu from '@/pages/system/SysMenu'
import SysLog from '@/pages/system/SysLog'
import SysUser from '@/pages/system/SysUser'
import Dept from '@/pages/system/Dept'
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router)
export default new Router({
    routes: [
        {
            path: '/',
            name: 'Home',
            component: Home,
            redirect: 'index',
            children: [
                {
                    path: '/index',
                    name: 'index',
                    component: index,
                    meta: { label: '首页' },
                },
                {
                    path: '/customer',
                    name: 'Customer',
                    component: Customer,
                    meta: { label: '客户管理' },
                    children: [
                        {
                            path: 'commonCustomer',
                            name: 'CommonCustomer',
                            component: CommonCustomer,
                            meta: { label: '公海客户' }
                        },
                        {
                            path: 'customerList',
                            name: 'CustomerList',
                            component: CustomerList,
                            meta: { label: '客户列表' }
                        }
                    ]
                },
                {
                    path: '/system',
                    name: 'System',
                    component: System,
                    meta: { label: '系统管理' },
                    children: [
                        {
                            path: 'sysRole',
                            name: 'SysRole',
                            component: SysRole,
                            meta: { label: '系统角色' }
                        },
                        {
                            path: 'sysUser',
                            name: 'SysUser',
                            component: SysUser,
                            meta: { label: '系统用户' }
                        },
                        {
                            path: 'sysMenu',
                            name: 'SysMenu',
                            component: SysMenu,
                            meta: { label: '系统菜单' }
                        },
                        {
                            path: 'sysLog',
                            name: 'SysLog',
                            component: SysLog,
                            meta: { label: '操作日志' }
                        },
                        {
                            path: 'dept',
                            name: 'Dept',
                            component: Dept,
                            meta: { label: '部门管理' }
                        }
                    ]
                },
                {
                    path: '/market',
                    name: 'Market',
                    component: Market,
                    meta: { label: '营销管理' },
                    children: [
                        {
                            path: 'myOrder',
                            name: 'MyOrder',
                            component: MyOrder,
                            meta: { label: '我的订单' }
                        },
                        {
                            path: 'allOrder',
                            name: 'AllOrder',
                            component: AllOrder,
                            meta: { label: '全部订单' }
                        }
                    ]
                },
            ]
        },
        {
            path: '/login',
            name: 'Login',
            component: Login,
            meta: { label: '登录' },
        }
    ]
})